package cn.exrick.xboot.modules.news.serviceimpl;

import cn.exrick.xboot.common.utils.SecurityUtil;
import cn.exrick.xboot.common.vo.PageVo;
import cn.exrick.xboot.modules.news.dao.mapper.newsMapper;
import cn.exrick.xboot.modules.news.entity.news;
import cn.exrick.xboot.modules.news.service.InewsService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试接口实现
 * @author Exrick
 */
@Slf4j
@Service
@Transactional
public class InewsServiceImpl extends ServiceImpl<newsMapper, news> implements InewsService {

    @Autowired
    private newsMapper newsMapper;
    @Autowired
    private SecurityUtil securityUtil;

    /**
     * 20190801
     * njp
     * 查询置顶新闻
     *
     */
    @Override
    public List<news> selectNewsByTop( @Param("news_is_top")String news_is_top){
        return newsMapper.selectNewsByTop(news_is_top);
    }

    /**
     * 20190830
     * njp
     * 新闻条件
     *
     */
    @Override
    public List<news> selectNewsVoMap( @Param("news")news info){
        return newsMapper.selectNewsVoMap(info);
    }

    /**
     * 20190830
     * njp
     * portal新闻条件查询
     *
     */
    @Override
    public List<news> selectPortalNewsVoMap( @Param("news")news info){
        return newsMapper.selectPortalNewsVoMap(info);
    }

    /**
     * 20191114
     * njp
     * 左连接新闻条件
     *
     */
    @Override
    public List<news> selectPortalNewsvoDict( @Param("news")news info){
        return newsMapper.selectPortalNewsvoDict(info);
    }

    /**
     * 20191114
     * njp
     * 左连接新闻条件分页
     *
     */
    @Override
    public IPage<news>selectNewsvoDictPage(Page page , @Param("news")news info,Boolean openDataFilter){
        // 数据权限
        List<String> depIds = securityUtil.getDeparmentIds();

      return   newsMapper.selectNewsvoDictPage(page,info);
    }

    /**
     * 20191230
     * njp
     * 左连接新闻条件分页(APP)
     *
     */
    @Override
    public IPage<news> selectAPPNewsvoDictPage(Page page , @Param("news")news info){
        return newsMapper.selectAPPNewsvoDictPage(page,info);
    }

    /**
     * 20191230
     * njp
     * 左连接新闻条件分页(APP)
     *
     */
    public IPage<news> selectPortalNewsvoDictPage(Page page , @Param("news")news info){
        return newsMapper.selectPortalNewsvoDictPage(page,info);
    }

    /**
     * 20200428
     * njp
     * 通过infoId查询本地新闻
     *
     */
    @Override
    public List<news> selectNewsByInfoId( String infoId){
       return newsMapper.selectNewsByInfoId(infoId);
    }
}